//
//  CLList+Oper.m
//  chanlin
//
//  Created by Ryan on 14-11-2.
//  Copyright (c) 2014年 chanlin. All rights reserved.
//

#import "CLList+Oper.h"
#import "NSObject+sagittarius.h"
#import "CLUrl.h"

@implementation CLList (Oper)

- (void)proInitwithClassDictionary:(NSDictionary *)dic{
    self.classId=[dic sgrGetStringForKey:@"classid"];
    self.info=[dic sgrGetStringForKey:@"classintro"];
    self.title=[dic sgrGetStringForKey:@"classname"];
    self.thumnail=[dic sgrGetStringForKey:@"classimg"];
    self.style=CLList_style_topic_sub;
    self.link=CLList_sub;
    self.cHeight=62.f+7;
}

- (void)proInitwithDictionary:(NSDictionary *)dic{
    self.itemId=[dic sgrFGetStringForKey:@"id"];
    self.title=[dic sgrFGetStringForKey:@"title"];
    
    self.comment=[dic sgrGetIntForKey:@"comment"];
    self.link=[dic sgrGetIntForKey:@"type"];
   // self.url=[dic sgrGetStringForKey:@"url"];
    if(self.link==MININT){
        self.link=CLList_doc;
    }
    self.info=[dic sgrGetStringForKey:@"intro"];
    self.sub=[dic sgrGetStringForKey:@"sub"];
    self.thumnail=[dic sgrGetStringForKey:@"titlepic"];
    self.style=[dic sgrGetIntForKey:@"showtype"];
    self.url=[dic sgrGetStringForKey:@"url"];
    //self.url=@"http://i.ifeng.com";
    self.status=[dic sgrGetStringForKey:@"live_status"];
    self.audioTime=[dic sgrGetStringForKey:@"audiotime"];

   
    if(self.style==MININT){
        self.style=_isStrNULL(self.thumnail)?CLList_style_doc:CLList_style_doc_img;
    }
    if(self.style==CLList_style_slide){
        NSArray *imgs=[dic sgrGetArrayForKey:@"morepic"];
        self.slider1=[imgs sgrGetStringForIndex:0];
        self.slider2=[imgs sgrGetStringForIndex:1];
        self.slider3=[imgs sgrGetStringForIndex:2];
        self.cHeight=128.f;
    }else{
        self.cHeight=78.f;
    }
    //http://appv2.chanlin.org/d/file/20141105/hefengdonglai.mp3
    NSString *audio=[dic sgrGetStringForKey:@"audio"];
   // audio=@"http://appv2.chanlin.org/d/file/20141105/hefengdonglai.mp3";
    if(_isStrNotNull(audio) && self.link==CLList_audio ){
        self.audio=audio;
        self.style=CLList_style_audio;
        self.cHeight=80.f;
    }
}

@end
